using Test


# 3.1
@test typemin(Int64) == -9223372036854775808
@test typemax(UInt32) == 0xffffffff

x = 20
y = UInt32(20)
@test y == 0x00000014

@test typeof(x) == Int64
@test typeof(y) == UInt32

@test typeof(3000000000) == Int64
@test typeof(20) ==Int64
@test signed(UInt32(20)) == 20
@test unsigned(-2) == 0xfffffffffffffffe
@test unsigned(2) == 0x0000000000000002
@test signed(unsigned(-2)) == -2
@test signed(typemax(UInt32)) == -1
@test bitstring(-1) == "1111111111111111111111111111111111111111111111111111111111111111"
@test bitstring(1) == "0000000000000000000000000000000000000000000000000000000000000001"
@test bitstring(Int8(1)) == "00000001"
@test typeof(0x01) == UInt8
@test typeof(0x0123) == UInt16
@test typeof(0x1234567) == UInt32
@test typeof(0x0123456789abcdef) == UInt64
@test typeof(0b10) == UInt8 
@test typeof(0o10 ) == UInt8 

@test Int64(0x1) == 1
@test signed(0b10011) == 19
@test typeof(signed(0b10011)) == Int8

@test bitstring(true) == "00000001"
@test bitstring(false) == "00000000"
@test bitstring(Int8(1)) == "00000001"
@test bitstring(Int8(0)) == "00000000"

@test Int8(true) == 1
@test UInt128(true) == 0x00000000000000000000000000000001
@test Int32(false) == 0

@test Bool(UInt8(1)) == true
@test Bool(Int64(1)) == true
@test Bool(0) == false

try
    Bool(10)
catch ex
    if isa(ex, InexactError)
        println(ex)
    end
end
try
    Bool(-10)
catch ex
    if isa(ex, InexactError)
        println(ex)
    end
end

# 3.2

@test bitstring(1.0) == "0011111111110000000000000000000000000000000000000000000000000000"
@test bitstring(-1.23) == "1011111111110011101011100001010001111010111000010100011110101110"
@test bitstring(2.5e-4) == "0011111100110000011000100100110111010010111100011010100111111100"

@test typeof(0.5f0) == Float32
@test typeof(2.5f-4) == Float32
@test Float32(0.5) == 0.5f0

@test 988_765.000_1234_05 == 988765.000123405
@test 10_000_000 == 10000000

@test 0xdeaf_beef == 0xdeafbeef
@test 0b1011_0010 == 0xb2

# 3.2.2






